<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <#include "/pubHeadStyle.html">
</head>
<body>
<!-- 表单布局 -->
<div class="layui-fluid bpmAuthorizeAdd" style="height: 400px; overflow: auto">
    <div class="layui-row" style="border-top: 1px solid #ccc;">
        <div class="layui-col-sm2">
            <label class="layui-form-label" style="text-align: right;">权限描述</label>
        </div>
        <div class="layui-col-sm10">
            <div class="layui-form layui-input-line">
                <input type="text" name="authorizeDesc" id="authorizeDesc" lay-verify="required" autocomplete="off"
                       placeholder="" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md2 layui-col-sm2">
            <label class="layui-form-label" style="text-align: right;">权限类型</label>
        </div>
        <div class="layui-col-md10 layui-col-sm10">
            <div class="layui-form layui-input-block">
                <input id="authorizeTypeStart" type="checkbox" name="authorizeTypes" title="启动" value="start" lay-skin="primary" lay-filter="authorizeTypeStartClick">
                <input id="authorizeTypeManagement" type="checkbox" name="authorizeTypes" title="定义" value="management" lay-skin="primary" lay-filter="authorizeTypeManagementClick">
                <input id="authorizeTypeTask" type="checkbox" name="authorizeTypes" title="任务" value="task" lay-skin="primary" lay-filter="authorizeTypeTaskClick">
                <input id="authorizeTypeInstance" type="checkbox" name="authorizeTypes" title="实例" value="instance" lay-skin="primary" lay-filter="authorizeTypeInstanceClick">
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-sm2">
            <div class="layui-form-label" style="text-align: right;">授权人员名称</div>
        </div>
        <div class="layui-col-sm10">
            <div class="layui-form layui-input-block">
                <div id="authorizeUserBtn" style="margin-bottom: 10px;">
                    <button type="button" class="layui-btn layui-btn-sm" id="selectAuthorizeUser">
                        <i class="layui-icon layui-icon-user"></i>选择
                    </button>
                    <button type="button" class="layui-btn layui-btn-sm" id="resetAuthorizeUserTable">
                        <i class="layui-icon layui-icon-refresh"></i>重置
                    </button>
                </div>
                <table id="authorizeUserTable" lay-filter="authorizeUserTable"></table>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-sm2">
            <div class="layui-form-label" style="text-align: right;">授权流程名称</div>
        </div>
        <div class="layui-col-sm10">
            <div class="layui-form layui-input-block">
                <div id="authorizeActBtn" >
                    <button type="button" class="layui-btn layui-btn-sm" id="selectAuthorizeAct">
                        <i class="layui-icon layui-icon-set"></i>选择
                    </button>
                    <button type="button" class="layui-btn layui-btn-sm" id="resetAuthorizeActTable">
                        <i class="layui-icon layui-icon-refresh"></i>重置
                    </button>
                    <button type="button" class="layui-btn layui-btn-danger layui-btn-sm" id="deleteAuthorizeActTable">
                        <i class="layui-icon layui-icon-delete"></i>删除
                    </button>
                </div><div id="authorizeActRightContentTool" style="display: inline-flex;">
                <fieldset class="layui-elem-field" id="authorizeActDefDiv" style="display:none;float: left;margin-right: 10px;">
                    <legend>定义</legend>
                    <div class="layui-field-box">
                        <input id="m_edit" type="checkbox" name="m_right" title="设计" value="m_edit" lay-skin="primary" lay-filter="m_edit">
                        <input id="m_del" type="checkbox" name="m_right" title="删除" value="m_del" lay-skin="primary" lay-filter="m_del">
                        <input id="m_start" type="checkbox" name="m_right" title="启动" value="m_start" lay-skin="primary" lay-filter="m_start">
                        <input id="m_set" type="checkbox" name="m_right" title="设置" value="m_set" lay-skin="primary" lay-filter="m_set">
                        <input id="m_clean" type="checkbox" name="m_right" title="清除数据" value="m_clean" lay-skin="primary" lay-filter="m_clean">
                    </div>
                </fieldset>
                <fieldset class="layui-elem-field" id="authorizeActInsDiv" style="display:none;width: 180px;">
                    <legend>实例</legend>
                    <div class="layui-field-box">
                        <input id="i_del" type="checkbox" name="i_right" title="删除" value="i_del" lay-skin="primary" lay-filter="i_del">
                        <input id="i_log" type="checkbox" name="i_right" title="日志" value="i_log" lay-skin="primary" lay-filter="i_log">
                    </div>
                </fieldset></div>
                <table id="authorizeActTable" lay-filter="authorizeActTable"></table>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="bar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','form','table','setter'],function(){
        var $ = layui.$;
        var form = layui.form;
        var table = layui.table;
        var setter = layui.setter;

        var id = "${id}";
        var type = "${type}";
        $('head').append('<link href="/css/workflow.css" rel="stylesheet" type="text/css" />');
        // 滚动条显示
        $('.layui-layout-body').css('overflow','auto');
        // 允许所有人访问标记
        layui.allowAllUsersFlag = false;

        // 权限类型
        layui.authorizeTypesData = ['','','',''];

        // 授权人员表格数据
        layui.authorizeUserTableData = [];

        // 授权流程表格数据
        layui.authorizeActTableData = [];

        // 权限类型选中状态
        var authorizeTypeManagementChecked = false,
            authorizeTypeInstanceChecked = false;

        // 授权流程->授权内容类型
        var actManageTypes = ['m_edit','m_del','m_start','m_set','m_clean','i_del','i_log'];

        // 授权流程表头工具栏checkbox选择状态
        var authorizeActDefAllChecked = [true,true,true,true,true,true,true];
        //全局使用。即所有弹出层都默认采用，但是单个配置skin的优先级更高
        layer.config({
            skin: 'btn-class'
        })
        // 如果是修改，初始化数据
        if(id){
            $.ajax({
                url: serverPath.workflowPath + setter.workflowLinkPath + 'bpmDefAuthorize/get',
                method: 'post',
                dataType: 'json',
                data: {
                    id: id
                },
                success: function(data){
                    if(data.code !== 0){
                        layer.msg(data.msg, {time: 2500, icon:5});
                        return false;
                    }
                    // 初始化权限描述
                    $('#authorizeDesc').val(data.data.authorizeDesc);
                    // 初始化权限类型
                    layui.each(data.data.authType,function(index,item){
                        switch (item.authorizeType) {
                            case 'start':
                                layui.authorizeTypesData[0] = 'start';
                                $("#authorizeTypeStart").prop("checked", "checked");
                                break;
                            case 'management':
                                authorizeTypeManagementChecked = true;
                                $("#authorizeActDefDiv").show();
                                layui.authorizeTypesData[1] = 'management';
                                $("#authorizeTypeManagement").prop("checked", "checked");
                                break;
                            case 'task':
                                layui.authorizeTypesData[2] = 'task';
                                $("#authorizeTypeTask").prop("checked", "checked");
                                break;
                            case 'instance':
                                authorizeTypeInstanceChecked = true;
                                $("#authorizeActInsDiv").show();
                                layui.authorizeTypesData[3] = 'instance';
                                $("#authorizeTypeInstance").prop("checked", "checked");
                                break;
                        }
                    });
                    // 初始化授权人员
                    layui.each(data.data.authUser,function(index,item){
                        switch(item.rightType){
                            case 'all':
                                layui.allowAllUsersFlag = true;
                                layui.authorizeUserTableData = [{rightType:'all', rightTypeName: '所有用户', ownerList:[{ownerId: '0',ownerName: 'all'}]}];
                                break;
                            case 'user':
                                var userData = null;
                                layui.each(layui.authorizeUserTableData,function(index,item){
                                    if(item.rightType === 'user'){
                                        userData = item;
                                        return true;
                                    }
                                });
                                if(!userData){
                                    userData = {rightType: 'user', rightTypeName: '用户授权', ownerList: []};
                                    layui.authorizeUserTableData.push(userData);
                                }
                                userData.ownerList.push({ownerId: item.ownerId,ownerName: item.ownerName});
                                break;
                            case 'role':
                                var roleData = null;
                                layui.each(layui.authorizeUserTableData,function(index,item){
                                    if(item.rightType === 'role'){
                                        roleData = item;
                                        return true;
                                    }
                                });
                                if(!roleData){
                                    roleData = {rightType: 'role', rightTypeName: '角色授权', ownerList: []};
                                    layui.authorizeUserTableData.push(roleData);
                                }
                                roleData.ownerList.push({ownerId: item.ownerId,ownerName: item.ownerName});
                                break;
                            case 'publicRole':
                                var publicRoleData = null;
                                layui.each(layui.authorizeUserTableData,function(index,item){
                                    if(item.rightType === 'publicRole'){
                                        publicRoleData = item;
                                        return true;
                                    }
                                });
                                if(!publicRoleData){
                                    publicRoleData = {rightType: 'publicRole', rightTypeName: '公共角色授权', ownerList: []};
                                    layui.authorizeUserTableData.push(publicRoleData);
                                }
                                publicRoleData.ownerList.push({ownerId: item.ownerId,ownerName: item.ownerName});
                                break;
                            case 'org':
                                var orgData = null;
                                layui.each(layui.authorizeUserTableData,function(index,item){
                                    if(item.rightType === 'org'){
                                        orgData = item;
                                        return true;
                                    }
                                });
                                if(!orgData){
                                    orgData = {rightType: 'org', rightTypeName: '组织授权', ownerList: []};
                                    layui.authorizeUserTableData.push(orgData);
                                }
                                orgData.ownerList.push({ownerId: item.ownerId,ownerName: item.ownerName});
                                break;
                            case 'position':
                                var positionData = null;
                                layui.each(layui.authorizeUserTableData,function(index,item){
                                    if(item.rightType === 'position'){
                                        positionData = item;
                                        return true;
                                    }
                                });
                                if(!positionData){
                                    positionData = {rightType: 'position', rightTypeName: '岗位授权', ownerList: []};
                                    layui.authorizeUserTableData.push(positionData);
                                }
                                positionData.ownerList.push({ownerId: item.ownerId,ownerName: item.ownerName});
                                break;
                        }
                    });
                    // 渲染授权人员表格
                    renderAuthorizeUserTable();
                    // 初始化授权流程
                    if(data.data.authAct.length === 0){
                        authorizeActDefAllChecked = [false,false,false,false,false,false,false];
                    }else{
                        layui.authorizeActTableData = $.map(data.data.authAct,function(item,index){
                            return {defKey: item.defKey,defName: item.defName,rightContent: JSON.parse(item.rightContent)};
                        });
                    }
                    // 渲染授权流程表格
                    renderAuthorizeActTable();
                    // 渲染授权流程（定义、实例）checkbox全选状态
                    renderAuthorizeActRightContentTool();
                    // 如果是详情
                    if(type === 'detail'){
                        $('#authorizeDesc').prop("disabled",true);
                        $('input[type="checkbox"]').prop("disabled",true);
                        form.render("checkbox");
                        $('#authorizeUserBtn').hide();
                        $('#authorizeActBtn').hide();
                        $('#authorizeActDefDiv').hide();
                        $('#authorizeActInsDiv').hide();
                    }
                }
            });
        }else{
            // 渲染授权人员表格
            renderAuthorizeUserTable();
            // 渲染授权流程表格
            renderAuthorizeActTable();
        }

        // 渲染授权人员表格函数
        function renderAuthorizeUserTable(){
            authorizeUserTableObjIn = table.render({
                elem: '#authorizeUserTable',
                cols: [[
                    {field:'rightTypeName', width:160, title: '权限分类'}
                    ,{field:'ownerList', title: '授权给', templet: function(d){
                            var ownerList = d.ownerList;
                            var html = '';
                            layui.each(ownerList,function(index,item){
                                if(d.rightType === 'all'){
                                    html += '<div>允许所有人访问</div>';
                                }
                                else if(d.rightType === 'user'){
                                    html += '<a href="javascript:void(0);"  style="color: blue;margin-right: 5px;" onclick=onAuthUserClick("'+ item.ownerId +'")>'+ item.ownerName +'</a>';
                                }else{
                                    html += '<span  style="margin-right: 5px;">'+ item.ownerName +'</span>';
                                }
                            });
                            return html;
                        }
                    }
                ]],
                data: layui.authorizeUserTableData,
                text: {
                    none: '没有授权的人员'
                }
            });
        }

        // 渲染授权流程表格函数
        function renderAuthorizeActTable(){
            authorizeActTableObjIn = table.render({
                elem: '#authorizeActTable',
                cols: [[
                    {type: 'checkbox', hide: type === 'detail'}
                    ,{field:'defName', width: 160, title: '流程名称'}
                    ,{field:'rightContent', title: '授权内容', templet: function(d){
                            var html = '';
                            var content = d.rightContent;
                            html += '<div class="act-def"'+
                              (authorizeTypeManagementChecked ? '>' : ' style="display: none;">') +
                              '<span style="margin-right: 15px;">定义:</span>'+
                              '<input type="checkbox" name="m_right" title="设计" value="m_edit" class="m_edit" lay-skin="primary" lay-filter="s_right"'+ (content['m_edit'] === 'Y' ? 'checked>' : '>') +
                              '<input type="checkbox" name="m_right" title="删除" value="m_del" class="m_del" lay-skin="primary" lay-filter="s_right"'+ (content['m_del'] === 'Y' ? 'checked>' : '>') +
                              '<input type="checkbox" name="m_right" title="启动" value="m_start" class="m_start" lay-skin="primary" lay-filter="s_right"'+ (content['m_start'] === 'Y' ? 'checked>' : '>') +
                              '<input type="checkbox" name="m_right" title="设置" value="m_set"  class="m_set" lay-skin="primary" lay-filter="s_right"'+ (content['m_set'] === 'Y' ? 'checked>' : '>') +
                              '<input type="checkbox" name="m_right" title="清除数据" value="m_clean"  class="m_clean" lay-skin="primary" lay-filter="s_right"'+ (content['m_clean'] === 'Y' ? 'checked>' : '>') +
                              '</div>'+
                              '<div class="act-ins"'+
                              (authorizeTypeInstanceChecked ? '>' : ' style="display: none;">') +
                              '<span style="margin-right: 15px;">实例:</span>'+
                              '<input type="checkbox" name="i_right" title="删除" value="i_del" class="i_del" lay-skin="primary" lay-filter="s_right"'+ (content['i_del'] === 'Y' ? 'checked>' : '>') +
                              '<input type="checkbox" name="i_right" title="日志" value="i_log"  class="i_log" lay-skin="primary" lay-filter="s_right"'+ (content['i_log'] === 'Y' ? 'checked>' : '>') +
                              '</div>';
                            return html;
                        },
                        event: 'actRightEdit'
                    }
                    ,{ title: '删除', toolbar: '#bar', width: type === 'detail' ? 0 : 80, align: 'center', hide: type === 'detail'}
                ]],
                data: layui.authorizeActTableData,
                text: {
                    none: '没有授权的流程'
                }
            });
        }

        // “权限类型-启动”checkbox监听事件
        form.on('checkbox(authorizeTypeStartClick)',function(data){
            layui.authorizeTypesData[0] = data.elem.checked ? 'start' : '';
        });
        // “权限类型-定义”checkbox监听事件
        form.on('checkbox(authorizeTypeManagementClick)', function(data){
            if(data.elem.checked){
                authorizeTypeManagementChecked = true;
                layui.authorizeTypesData[1] = 'management';
                $("#authorizeActDefDiv").show();
                $(".act-def").show();
            }else{
                authorizeTypeManagementChecked = false;
                layui.authorizeTypesData[1] = '';
                $("#authorizeActDefDiv").hide();
                $(".act-def").hide();
                var managementTypes = ['m_edit','m_del','m_start','m_set','m_clean'];
                layui.each(layui.authorizeActTableData,function(index,item){
                    layui.each(managementTypes,function(i,v){
                        item.rightContent[v] = "N";
                    });
                });
            }
            renderAuthorizeActRightContentTool();
            renderAuthorizeActTableCheckbox();
        });
        // “权限类型-任务”checkbox监听事件
        form.on('checkbox(authorizeTypeTaskClick)',function(data){
            layui.authorizeTypesData[2] = data.elem.checked ? 'task' : '';
        });
        // “权限类型-实例”checkbox监听事件
        form.on('checkbox(authorizeTypeInstanceClick)', function(data){
            if(data.elem.checked){
                authorizeTypeInstanceChecked = true;
                layui.authorizeTypesData[3] = 'instance';
                $("#authorizeActInsDiv").show();
                $(".act-ins").show();
            }else{
                authorizeTypeInstanceChecked = false;
                layui.authorizeTypesData[3] = '';
                $("#authorizeActInsDiv").hide();
                $(".act-ins").hide();
                var instanceTypes = ['i_log','i_del'];
                layui.each(layui.authorizeActTableData,function(index,item){
                    layui.each(instanceTypes,function(i,v){
                        item.rightContent[v] = "N";
                    });
                });
            }
            renderAuthorizeActRightContentTool();
            renderAuthorizeActTableCheckbox();
        });
        // “授权流程-定义-（设计、删除、启动、设置、清除数据）”checkbox监听事件
        form.on('checkbox(m_edit)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        form.on('checkbox(m_del)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        form.on('checkbox(m_start)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        form.on('checkbox(m_set)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        form.on('checkbox(m_clean)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        // “授权流程-实例-（删除、日志）”checkbox监听事件
        form.on('checkbox(i_del)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        form.on('checkbox(i_log)', function(data){
            batchSetActRightContent(data);
            renderAuthorizeActTableCheckbox();
        });
        // 根据授权流程表格数据批量渲染授权流程表格授权内容的checkbox
        function renderAuthorizeActTableCheckbox(){
            authorizeActTableObjIn.reload({data: layui.authorizeActTableData});
        }
        // 授权流程->批量设置授权内容
        function batchSetActRightContent(data){
            layui.each(layui.authorizeActTableData,function(index,item){
                item.rightContent[data.value] = data.elem.checked ? "Y" : "N";
            });
        }
        // 每个流程的checkbox选择事件
        var actRightName = null;
        var actRightNameStatus = false;
        form.on('checkbox(s_right)',function(obj){
            actRightName = obj.value;
            actRightNameStatus = obj.elem.checked;
        });
        // 授权流程表格行事件
        table.on('tool(authorizeActTable)',function(obj){
            switch (obj.event) {
                case 'del':
                    layer.confirm("确定删除吗?",{icon:0},function(index){
                        obj.del();
                        for(var i = 0; i < layui.authorizeActTableData.length; i++){
                            if(obj.data.defKey === layui.authorizeActTableData[i].defKey){
                                layui.authorizeActTableData.splice(i,1);
                                break;
                            }
                        }
                        renderAuthorizeActRightContentTool();
                        layer.close(index);
                    });
                    break;
                case 'actRightEdit':
                    obj.data.rightContent[actRightName] = actRightNameStatus ? 'Y' : 'N';
                    renderAuthorizeActRightContentTool();
                    break;
            }
        });
        // 选择授权人员弹窗
        $("#selectAuthorizeUser").click(function(){
            var selectUserDialogWin = null;
            parent.layer.open({
                type: 2,
                title: '选择授权人员',
                area: ['768px', '400px'],
                skin: 'btn-class',
                content: serverPath.workflowPath + setter.workflowLinkPath + 'bpmDefAuthorize/view/userDialog',
                btn: ['确定','取消'],
                btnAlign: 'c',
                success: function(layero, index){
                    selectUserDialogWin = parent.window[layero.find('iframe')[0]['name']];
                    selectUserDialogWin.layui.defaultAuthorizeUserTableData = layui.authorizeUserTableData;
                },
                yes: function(index,layero){
                    if(selectUserDialogWin.layui.allowAllUsersFlag){
                        layui.authorizeUserTableData = [{rightType:'all', rightTypeName: '所有用户', ownerList:[{ownerId: '0',ownerName: 'all'}]}];
                    }else{
                        setAuthorizeUserTableData(selectUserDialogWin.layui.selectAuthorizeUserTableData);
                    }
                    authorizeUserTableObjIn.reload({data: layui.authorizeUserTableData});
                    parent.layer.close(index);
                },
                shadeClose: false
            });
        });
        // 重置授权人员表格
        $("#resetAuthorizeUserTable").click(function(){
            layer.confirm("确认重置授权对象内容?",{icon:3},function(index){
                layui.allowAllUsersFlag = false;
                layui.authorizeUserTableData = [];
                authorizeUserTableObjIn.reload({data: []});
                layer.close(index);
            });
        });
        // 选择授权流程弹窗
        $("#selectAuthorizeAct").click(function(){
            var actSelectWin;
            var body;
            parent.layer.open({
                type: 2,
                title: '选择流程',
                resize:false,
                area: ['1000px', '600px'],
                btn:["保存","取消"],
                content: serverPath.workflowPath + setter.workflowLinkPath + 'bpmDefAuthorize/view/actDialog',
                shadeClose: false,
                success: function(layero, index){
                    body = parent.layer.getChildFrame('body',index);
                    actSelectWin = parent.window[layero.find('iframe')[0]['name']];
                    // 初始化已选择的流程
                    if(layui.authorizeActTableData.length > 0) {
                        actSelectWin.layui.actList = layui.authorizeActTableData;
                    }
                },
                yes: function(index,layero){
                    var theUserList = body.find("input[name=actList]").val();
                    layui.authorizeActTableData = JSON.parse(theUserList);
                    authorizeActTableObjIn.reload({data: layui.authorizeActTableData});
                    parent.layer.close(index);
                    renderAuthorizeActRightContentTool();
                }
            });
        });
        // 重置授权流程表格
        $("#resetAuthorizeActTable").click(function(){
            layer.confirm("确认重置授权流程内容?",{icon:3},function(index){
                layui.authorizeActTableData = [];
                authorizeActTableObjIn.reload({data: []});
                renderAuthorizeActRightContentTool();
                layer.close(index);
            });
        });
        // 多选删除授权流程
        $("#deleteAuthorizeActTable").click(function(){
            // 获取选择的所有授权流程
            var checkStatus = table.checkStatus('authorizeActTable');
            var authorizeActSelections = checkStatus.data;
            if(authorizeActSelections.length <= 0){
                layer.open({
                    content: '请至少选择一条数据'
                });
                return false;
            }
            layer.confirm("确认删除吗?",{icon:0},function(index){
                if(checkStatus.isAll){
                    layui.authorizeActTableData = [];
                    authorizeActTableObjIn.reload({data: []});
                }else{
                    layui.authorizeActTableData = $.map(layui.authorizeActTableData,function(v){
                        if(!inObjArray(v,authorizeActSelections)) return v;
                    });
                    authorizeActTableObjIn.reload({data: layui.authorizeActTableData});
                }
                renderAuthorizeActRightContentTool();
                layer.close(index);
            });
        });
        // 赋值layui.authorizeUserTableData
        function setAuthorizeUserTableData(data){
            layui.authorizeUserTableData = [];
            layui.each(data,function(index,item){
                if(item.ownerList.length > 0){
                    layui.authorizeUserTableData.push(item);
                }
            });
        }
        // 判断对象数组中是否包含给定对象
        function inObjArray(obj,objArray){
            var hasObj = false;
            $.each(objArray,function(i,n){
                if(n.defKey === obj.defKey) {
                    hasObj = true;
                    return true;
                }
            });
            return hasObj;
        }
        // 根据授权流程的授权内容渲染授权流程表头的checkbox
        function renderAuthorizeActRightContentTool() {
            authorizeActDefAllChecked = [true,true,true,true,true,true,true];
            if(layui.authorizeActTableData.length === 0){
                authorizeActDefAllChecked = [false,false,false,false,false,false,false];
            }
            layui.each(layui.authorizeActTableData, function (index,item) {
                parseAuthorizeActDefAllChecked(item.rightContent);
            });
            layui.each(authorizeActDefAllChecked,function(i,v){
                $('#'+actManageTypes[i]).prop("checked", v);
            });
            form.render("checkbox");
        }
        // 判断授权流程（定义、实例）是否都选
        function parseAuthorizeActDefAllChecked(rightContent){
            layui.each(actManageTypes,function(i,v){
                if(rightContent[v] === 'N') authorizeActDefAllChecked[i] = false;
            });
        }

        // 点击授权人员弹窗
        window.onAuthUserClick = function(ownerId){
            parent.layer.open({
                type: 2,
                title: '人员详细信息',
                area: ['938px', '620px'],
                content: serverPath.systemPath + setter.sysLinkPath + 'sysUser/view/view?userId=' + ownerId
            });
        }
    });
</script>
</body>
</html>